{{ $version := .File.BaseFileName }}
{{ $latest := index site.Data.docs.versions 0 }}
{{ $isLatest := eq $version $latest }}
{{ $release := index site.Data.docs.releases $version }}
{{ $highlights := where (where site.RegularPages "Section" "highlights") ".Params.release" "eq" $version }}
<a href="{{ .RelPermalink }}">
  <div
    class="border shadow-sm rounded-md py-4 px-6 dark:border-gray-700 hover:border-secondary dark:hover:border-primary">
    <span class="flex items-center justify-between">
      <span class="flex items-center space-x-4">
        <span class="font-bold dark:text-gray-300 text-lg">
          Version {{ .File.BaseFileName }}
        </span>

        {{ if $isLatest }}
        {{ partial "badge.html" (dict "word" "latest" "color" "green") }}
        {{ end }}
      </span>

      {{ with $release.date }}
      {{ $date := $release.date | dateFormat "January 2, 2006" }}
      <time datetime="{{ $date }}" class="font-sm font-light tracking-tight text-dark dark:text-gray-300">
        {{ $date }}
      </time>
    </span>
    {{ end }}
    </span>
  </div>
</a>

{{ if or $release.description $highlights }}
<div class="border-l border-gray-100 dark:border-gray-800 pl-8 flex flex-col space-y-4 py-2">
  {{ with $release.description }}
  <div class="prose dark:prose-dark max-w-none">
    {{ . | markdownify }}
  </div>
  {{ end }}

  {{ with $highlights }}
  {{ $id := printf "highlights-%s" $version }}
  <div class="flex flex-col space-y-2">
    <span class="prose dark:prose-dark max-w-none">
      {{ partial "heading.html" (dict "text" "Highlights" "level" 3 "id" $id) }}
    </span>

    <div class="flex flex-col space-y-1">
      {{ range . }}
      {{ .Render "brief" }}
      {{ end }}
    </div>
  </div>
  {{ end }}
</div>
{{ end }}